package com.jandar.spider.config;

import com.jandar.spider.config.property.SpiderConfig;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.springframework.stereotype.Component;



/**
 * @author gaochenyang
 * @title: selenium
 * @projectName java_reptile
 * @description: TODO
 * @date 2020/6/310:54 上午
 */
@Slf4j
@Component
public class SeleniumConfig {

    @Autowired
    private SpiderConfig application;

    /**
     * Selenium 配置
     *
     * @return
     */
    public org.openqa.selenium.WebDriver init() {
        System.setProperty(application.getChromedriver().getUsr(), application.getChromedriver().getPath());
        ChromeOptions chromeOptions = new ChromeOptions();
//        设置 chrome 的无头模式
//        chromeOptions.setHeadless(Boolean.TRUE);
        return new ChromeDriver(chromeOptions);
    }


}
